{include file="header" /}
<div class="fly-msg" style="margin-bottom: 20px;">在线充值 </div>
<div class="layui-row layui-col-space20">
    <div class="layui-col-md12">
        <div class="fly-home fly-panel" style="text-align: left">
            <form class="layui-form" action="javascript:;">
                <div class="layui-form-item">
                    <label class="layui-form-label">余额：</label>
                    <div class="layui-form-mid layui-word-aux"><span style="font-weight:bold;color: red">	{$userinfo.amount} </span>元</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">充值金额：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="info[price]" required lay-verify="required|number" lay-reqText="请输入要充值的金额" placeholder="充值金额" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">请输入要充值的金额</div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">充值方式：</label>
                    <div class="layui-input-block">
                        {foreach $pay_res as $k=> $v}
                        <input type="radio" name="info[pay_type]" value="{$v.pay_id}"  lay-filter="pay_type"  title="{$v.name}" >
                        {/foreach}
                      <!--  <input type="radio" name="pay_type" value="2" title="微信">-->
                        <input type="hidden" required  lay-verify="required" lay-reqText="请选择充值方式" id="pay_type" value="">
                        <input type="hidden" name="info[payment]" required  lay-verify="required" lay-reqText="请选择充值方式" id="payment" value="">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">E-mail：</label>
                    <div class="layui-input-inline">
                        <input type="email" name="info[email]" required lay-verify="required|email" placeholder="E-mail" autocomplete="off" class="layui-input" value="{$userinfo.email}" lay-reqText="请输入email">
                    </div>
                    <div class="layui-form-mid layui-word-aux">请输入email</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓 名：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="info[name]" required lay-verify="required" placeholder="姓 名：" autocomplete="off" class="layui-input" value="{$userinfo.username}" lay-reqText="请输入姓名">
                    </div>
                    <div class="layui-form-mid layui-word-aux">请输入姓名</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">电 话：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="info[telephone]"  placeholder="电 话：" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">格式：010-88888888或13888888888</div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备 注：</label>
                    <div class="layui-input-block">
                        <textarea name="info[usernote]" placeholder="备 注：" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">验证码：</label>
                    <div class="layui-input-inline">

                        <input type="text" name="info[code]" id="code" lay-verify="required" lay-reqText="请输入验证码" placeholder="验证码" autocomplete="off" class="layui-input" maxlength="4">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <img id="verify" src="{:url('api/checkcode/getVerify','font_size=18&imageW=130&imageH=38')}" alt="验证码" class="captcha" style="height: 44px">
                        </div>
                    <div class="layui-form-mid layui-word-aux">请输入验证码</div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input class="layui-btn" type="button" lay-submit lay-filter="formDemo" value="立即提交">
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>




        </div>
    </div>

</div>
{include file="footer" /}

<script>
    //Demo
    layui.use(['form', 'layer', 'jquery'], function(){
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;
        form.on('radio(pay_type)', function(data){
            $('#pay_type').val(data.value);
            $('#payment').val($(data.elem).attr('title'));
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
           console.log(data.field);
           var datas=data.field;
           $.post('{:url("OnlineRecharge/index")}',datas,function (res) {
               $("#code").val('');
               $("#verify").click();
               if (res.code==1){


                   layer.msg(res.data.msg_title,{icon:1},function () {

                    window.location.href=res.url;
                   })
               } else{
                   layer.msg(res.data.msg_title,{icon:2},function () {


                   })
               }

               console.log(res)
           },'json');
            return false;
        });
        //刷新验证码
        $("#verify").click(function() {
            var verifyimg = $("#verify").attr("src");
            $("#verify").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
        });
    });

</script>